﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Xml.Linq;
using iShoppingDAO;
using iShoppingDTO;

namespace iShoppingBUS
{
    public class LoaiSanPhamBUS
    {
        public static List<LoaiSanPhamDTO> LayDSLoaiSanPham()
        {
            DataTable dt = LoaiSanPhamDAO.LayDSLoaiSanPham();
            int i, n = dt.Rows.Count;
            List<LoaiSanPhamDTO> dslsp = new List<LoaiSanPhamDTO>();
            foreach (DataRow dr in dt.Rows)
            {
                LoaiSanPhamDTO lsp = new LoaiSanPhamDTO();
                lsp.MaLoaiSanPham = dr["MaLoaiSanPham"].ToString();
                lsp.TenLoaiSanPham = dr["TenLoaiSanPham"].ToString();
                dslsp.Add(lsp);
            }
            return dslsp;
        }

        public static DataTable LayDSLoaiSanPhamO()
        {
            return LoaiSanPhamDAO.LayDSLoaiSanPham();
        }

        public static string LayMaTheoTen(string name)
        {
            return LoaiSanPhamDAO.LayMaTheoTen(name);
        }

        public static bool UpdateLoaiSanPham(LoaiSanPhamDTO loaiSanPhamDto)
        {
            return LoaiSanPhamDAO.UpdateLoaiSanPham(loaiSanPhamDto);
        }

        public static bool DeleteLoaiSanPham(string maLoai)
        {
            return LoaiSanPhamDAO.DeleteLoaiSanPham(maLoai);
        }

        public static bool InsertLoaiSanPham(LoaiSanPhamDTO loaiSanPhamDto)
        {
            return LoaiSanPhamDAO.InsertLoaiSanPham(loaiSanPhamDto);
        }
    }
}
